import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import enLocale from 'element-ui/lib/locale/lang/en'
import cnLocale from 'element-ui/lib/locale/lang/zh-CN'
import './assets/reset.css'
import './assets/default.css'
import store from './store/index' //引入状态管理 store
// 引用API文件
import $axios from './api/client'
import callbackCatch from '@/assets/mixins/callbackCatch'
import hasPermission from '@/assets/mixins/hasPermission'
import tableRowClick from '@/assets/mixins/tableRowClick'
import pagination from '@/assets/mixins/pagination'
import inputValid from '@/directives/input-valid.js'
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts

Vue.mixin(callbackCatch)
Vue.mixin(hasPermission)
Vue.mixin(tableRowClick)
Vue.mixin(pagination)
Vue.prototype.$axios = $axios
Vue.prototype.cloneObject = (obj) => JSON.parse(JSON.stringify(obj))
// 引入字体图标  涉及table中的展开和折叠图标
import './iconfont/iconfont.css'

//国际化
import VueI18n from 'vue-i18n'
Vue.use(VueI18n) // 通过插件的形式挂载
let locale = process.env.NODE_ENV === 'development'?'cn':sessionStorage.getItem('vuexState') ? JSON.parse(sessionStorage.getItem('vuexState')).basicInfo.language.lang : 'en'//国际化默认语言
const i18n = new VueI18n({
  locale,    // 语言标识
  //this.$i18n.locale // 通过切换locale的值来实现语言切换
  messages:{
    'cn':Object.assign(require('./assets/lang/cn'),cnLocale),   // 中文语言包
    'en':Object.assign(require('./assets/lang/en'),enLocale),   // 英文语言包
    'mm':require('./assets/lang/md')    //缅甸语言包
  }
})

import common from '@/utils/common'
Vue.config.productionTip = false
Vue.filter('dateFilter', (val) => {
  if (val === '---') return val
  else return val ? common.timestampToTime(val) : '---'
})

Vue.use(ElementUI, {
  i18n:(key, value) => i18n.t(key, value)
})
Vue.directive('input-valid', inputValid)

export default new Vue({
  i18n,
  render:h => h(App),
  router,
  store
  //JsBarcode
}).$mount('#app')
